package com.zjj.disk.pojo;

public enum TransactionType {
    EXPENDITURE("expenditure", "支出"),
    INCOME("income", "收入");

    private final String code;
    private final String name;

    TransactionType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String getNameByCode(String code) {
        for (TransactionType type : TransactionType.values()) {
            if (type.getCode().equals(code)) {
                return type.getName();
            }
        }
        return null; // 或者返回一个默认值或抛出异常
    }

    public static String getCodeByName(String name) {
        for (TransactionType type : TransactionType.values()) {
            if (type.getName().equals(name)) {
                return type.getCode();
            }
        }
        return null; // 或者返回一个默认值或抛出异常
    }
}
